"use strict"
angular.module("myApp")
.config(function($stateProvider, $urlRouterProvider) {
	$urlRouterProvider.otherwise("wait");
	$stateProvider.state("wait", {
		url: "/wait",
		templateUrl: "views/wait/wait.html"
	}).state("home", {
		url: "/home",
		templateUrl: "views/home/main/home.html",
		controller: "HomeController",
		resolve:{
            deps:["$ocLazyLoad",function($ocLazyLoad){
                return $ocLazyLoad.load("app/controllers/HomeController.js");
            }]
        }
	}).state("special", {
		url: "/special",
		templateUrl: "views/special/special.html",
		controller: "SpecialController",
		resolve:{
            deps:["$ocLazyLoad",function($ocLazyLoad){
                return $ocLazyLoad.load("app/controllers/SpecialController.js");
            }]
        }
	}).state("sort", {
		url: "/sort",
		templateUrl: "views/sort/sort.html",
		controller: "SortController",
		resolve:{
            deps:["$ocLazyLoad",function($ocLazyLoad){
                return $ocLazyLoad.load("app/controllers/SortController.js");
            }]
        }
	}).state("mine", {
		url: "/mine",
		templateUrl: "views/mine/mine.html",
		controller: "MineController",
		resolve:{
            deps:["$ocLazyLoad",function($ocLazyLoad){
                return $ocLazyLoad.load("app/controllers/MineController.js");
            }]
        }
	}).state("search", {
		url: "/search",
		templateUrl: "views/home/search/search.html",
		controller: "SearchController",
		resolve:{
            deps:["$ocLazyLoad",function($ocLazyLoad){
                return $ocLazyLoad.load("app/controllers/SearchController.js");
            }]
        }
	}).state("timelimit", {
		url: "/timelimit",
		templateUrl: "views/timelimit/timelimit.html",
		controller: "TimelimitController",
		resolve:{
            deps:["$ocLazyLoad",function($ocLazyLoad){
                return $ocLazyLoad.load("libs/js/timelimit.js");
            }]
        }
	}).state("detail", {
		url: "/detail",
		templateUrl: "views/home/detail/detail.html",
		resolve:{
            deps:["$ocLazyLoad",function($ocLazyLoad){
                return $ocLazyLoad.load("app/controllers/DetailController.js");
            }]
        }
	}).state("maker", {
		url: "/maker",
		templateUrl: "views/home/maker/maker.html",
		controller: "MakerController",
		resolve:{
            deps:["$ocLazyLoad",function($ocLazyLoad){
                return $ocLazyLoad.load("views/home/maker/maker.js");
            }]
        }
	}).state("cart", {
		url: "/cart",
		templateUrl: "views/home/cart/cart.html",
		controller: "CartController",
		resolve:{
            deps:["$ocLazyLoad",function($ocLazyLoad){
                return $ocLazyLoad.load("app/controllers/CartController.js");
            }]
        }
	}).state("sort.item", {//配置分类右侧列表路由
		url: "/item",
		templateUrl: "views/sort/item.html"
	}).state("SortItemList", {
		url: "/SortItemList",
		templateUrl: "views/sort/SortItemList.html"
	}).state("SortItemList.Goods",{
		url:"/Goods",
		templateUrl:"views/sort/Goods.html"
	})
})
.directive("hello",function(){
        return {
        	restrict: 'E',
	        transclude: false,
	          link:function(scope,element,attr){
		          //事件绑定
		          element.bind('mouseenter',function(){
		          		_sId = element.attr("data-id");//获取我要的ID
		          });
        	}
	   	}
})
.controller("indexController", ["$scope", "$http",function($scope,$http) {
		var h_hc = document.getElementsByClassName("h_hc")[0];
		$scope.hc = function() {
			if(h_hc.style["backgroundPosition"] == "0px -4.18667rem") {
				h_hc.style["backgroundPosition"] = " 0 -3.38667rem";
			} else {
				h_hc.style["backgroundPosition"] = "0 -4.18667rem";
			}
		};
		
		var h_meun = document.getElementsByClassName("h_meun")[0];
		$scope.hen=function(){
			h_hc.style["backgroundPosition"] = " 0 -3.38667rem";
			h_meun.style.display="none";
		}
		//选择的商品的总数
		$scope.zongshu = zongshu;
		
}])
//封装全局数据获取
.service("globalData",function($http){
    this.getSort = function(){
        return $http.get("./data/sort.json");
    }
    this.getGoods = function(){
    	 return $http.get("./data/goods.json");
    }
    this.getGoods_filter = function(){
    	 return $http.get("./data/goods_filter.json");
    }
    this.getHome = function(){
    	 return $http.get("./data/home.json");
    }
	    
});
